package com.zhiqiang.nativeplayer.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * author：paul
 * date：Created in 16:59 2022/11/21
 */
@Configuration
public class WebResourceConfig implements WebMvcConfigurer {
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry){
////        registry.addResourceHandler("/images/**")
////                .addResourceLocations("file:E:/a");
//        registry.addResourceHandler("/static/**")
//                .addResourceLocations("classpath:/static/greeting.html");
//
//    }


    /**
     * 跨域支持,设置所有请求可以跨域访问
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)
                .allowedOriginPatterns("*")
                .allowedHeaders("*")
                .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH")
                .maxAge(3600 * 24);


    }
}
